import 'package:flutter/material.dart';
import 'package:xinxuan/common/appbar_util.dart';
import 'package:get/get.dart';
import 'package:xinxuan/common/my_underline_tab_indicator.dart';
import 'package:xinxuan/common/scroll_configuration_common.dart';
import 'package:xinxuan/common/seckill_order_good_arr.dart';
import 'package:xinxuan/controllers/seckill_controller/seckill_order_page_controller.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:xinxuan/utils/color_util.dart';

class SeckillOrderPage extends StatelessWidget {

  @override
  Widget build(BuildContext context) {
    // Map<String, dynamic> argumentsMap = Get.arguments;
    // int tabIndex = argumentsMap['tabIndex'];
    return GetBuilder<SeckillOrderPageController>(
      init: SeckillOrderPageController(),
      builder: (controller) {
        return Scaffold(
          backgroundColor: pageBgColor,
          appBar: AppBarUtil(
            title: '盲盒订单',
            backgroundColor: pageBgColor,
          ),
          body: DefaultTabController(
            length: 5, 
            initialIndex: controller.tabIndex.value,
            child: Column(
              children: [
                ScrollConfigurationCommon(child: Container(
                  constraints: BoxConstraints(maxHeight: 44.h),
                  child: Material(
                    color: bgWhiteColor,
                    child: TabBar(  
                      indicator: MyUnderlineTabIndicator(
                        wantWidth: 20.w,
                        borderSide: BorderSide(
                          width: 5.h,
                          color: bgMainColor
                        )
                      ),
                      isScrollable: false,
                      indicatorColor: bgMainColor,
                      labelColor: mainTextColor,
                      unselectedLabelColor: textSubtitleColor,
                      labelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      unselectedLabelStyle: TextStyle(
                        fontSize: 14.sp
                      ),
                      onTap: (index) {
                        controller.tabIndex.value = index;
                        controller.getSeckillOrderList();
                      },
                      labelPadding: EdgeInsets.symmetric(horizontal: 0),
                      tabs: [
                        Container(
                          width: 75.w,
                          child: Tab(text: '全部'),
                        ),
                        Container(
                          width: 75.w,
                          child: Tab(text: '已预付'),
                        ),
                        Container(
                          width: 75.w,
                          child: Tab(text: '已中签'),
                        ),
                        // Container(
                        //   width: 68.w,
                        //   child: Tab(text: '已提货'),
                        // ),
                        Container(
                          width: 75.w,
                          child: Tab(text: '发货中'),
                        ),
                        Container(
                          width: 75.w,
                          child: Tab(text: '已完成'),
                        ),
                        // Tab(text: '待付款'),
                        // Tab(text: '待提货'),
                        // Tab(text: '已提货'),
                        // Tab(text: '已完成'),
                        // Tab(text: '已取消')
                      ]
                    ),
                  ),
                )),
                // Expanded(child: TabBarView(
                //   physics: NeverScrollableScrollPhysics(),
                //   children: controller.dataArr.map((item) {
                //     return Column(
                //       children: [
                //         SizedBox(height: 12.h),
                //         Expanded(
                //           child: SeckillOrderGoodArr(seckillOrderListVo: item, seckillOrderPageController: controller)
                //         )
                //       ],
                //     );
                //   }).toList()
                // ))
                Expanded(child: Column(
                  children: [
                    SizedBox(height: 12.h),
                    Expanded(
                      child: Obx(() => SeckillOrderGoodArr(seckillOrderListVo: controller.dataArr[controller.tabIndex.value], seckillOrderPageController: controller))
                    )
                  ],
                ))
              ],
            )
          ),
        );
      },
    );
  }
}